package com.qubuyer.business.mine.adapter

import android.graphics.Color
import com.blankj.utilcode.util.TimeUtils
import com.qubuyer.R
import com.qubuyer.databinding.ItemIncomeDetailBinding
import com.qubuyer.repository.entitys.IncomeEntity
import com.qubyer.widget.adapter.BindingRvAdapter
import java.text.SimpleDateFormat

/**
 * @author Susong
 * @date 创建时间2019/6/23
 * @description 收支明细adapter
 * @version
 */
class IncomeAdapter : BindingRvAdapter<IncomeEntity,ItemIncomeDetailBinding>() {

    override val itemLayout: Int
        get() = R.layout.item_income_detail

    override fun onBind(data: IncomeEntity, dataBinding: ItemIncomeDetailBinding) {
        dataBinding.tvTime.text = TimeUtils.millis2String(
            data.create_time,
            SimpleDateFormat("yyyy-MM-dd HH:mm")
        )
        if (data.money?.contains("-") == false) {
            dataBinding.tvPrice.setTextColor(Color.parseColor("#ff6809"))
        } else {
            dataBinding.tvPrice.setTextColor(Color.parseColor("#424242"))
        }
        dataBinding.host = this
        dataBinding.data = data
    }
}